﻿using System;

namespace AuctionServer.Domain
{
    public class AuctionInfo
    {
        public long Id { get; set; }
        /// <summary>
        /// 拍品名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 产品Id
        /// </summary>
        public long ProductId { get; set; }
        /// <summary>
        /// 商品Id
        /// </summary>
        public Guid ProductVariantId { get; set; }
        /// <summary>
        /// 重置秒数
        /// </summary>
        public int Interval { get; set; }
        /// <summary>
        /// 每次出价消耗金额
        /// </summary>
        public int PerPrice { get; set; }
        /// <summary>
        /// 购买价格
        /// </summary>
        public decimal BuyPrice { get; set; }
        /// <summary>
        /// 参考价格
        /// </summary>
        public decimal MarketPrice { get; set; }
        /// <summary>
        /// 是否可补差购买
        /// </summary>
        public bool CanBuy { get; set; }
        /// <summary>
        /// 0为不限,>0则为可补差购买数量
        /// </summary>
        public int BuyLimit { get; set; }
        /// <summary>
        /// 附加费
        /// </summary>
        public decimal AdditionalCharge { get; set; }
        /// <summary>
        /// 当前价格
        /// </summary>
        public decimal CurrentPrice { get; set; }

        /// <summary>
        /// 当前出价用户Id
        /// </summary>
        public long CurrentUserId { get; set; }
        /// <summary>
        /// 当前用户昵称
        /// </summary>
        public string CurrentNickName { get; set; }
        /// <summary>
        /// 上架时间
        /// </summary>
        public DateTime OnlineTime { get; set; }
        /// <summary>
        /// 开始时间
        /// </summary>
        public string StartTime { get; set; }
        /// <summary>
        /// 开始日期时间
        /// </summary>
        public DateTime StartDateTime { get { return DateTime.Parse(StartTime); } }
        /// <summary>
        /// 结束时间
        /// </summary>
        public string StopTime { get; set; }
        /// <summary>
        /// 结束日期时间
        /// </summary>
        public DateTime StopDateTime { get { return DateTime.Parse(StopTime); } }
        /// <summary>
        /// 预期成交时间
        /// </summary>
        public DateTime? ExpectedTime { get; set; }
        /// <summary>
        /// 实际成交时间
        /// </summary>
        public DateTime? ActualTime { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public AuctionStatus Status { get; set; }
        /// <summary>
        /// 创建者
        /// </summary>
        public string CreatedBy { get; set; }
        /// <summary>
        /// 创建日期时间
        /// </summary>
        public DateTime CreatedOn { get; set; }

        public override bool Equals(object obj)
        {
            var target = obj as AuctionInfo;
            if (target != null)
            {
                return Id == target.Id && Status == target.Status;
            } return false;
        }
        public override int GetHashCode()
        {
            var result = Id.GetHashCode();
            return result;
        }
    }
    public enum AuctionStatus : byte
    {
        Normal = 0,
        Stop,
        Dealt,
        Deleted
    }
}